package com.sixth.controller;

import com.sixth.annotation.FootprintAdvice;
import com.sixth.annotation.SearchRecordAdvice;
import com.sixth.bean.common.BasePageInfo;
import com.sixth.bean.common.BaseRespVo;
import com.sixth.bean.vo.WXGoodsCategoryVO;
import com.sixth.bean.vo.WXGoodsDetailVO;
import com.sixth.bean.vo.WXGoodsListVO;
import com.sixth.bean.vo.WXGoodsRelatedVO;
import com.sixth.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author lixinhang
 * @Time 2022/9/9 18:23
 */
@RestController
@RequestMapping("wx/goods")
public class WXGoodsController {

@Autowired
    GoodsService goodsService;

//查询全部商品个数并且返回
@RequestMapping("count")
public BaseRespVo wxGoodsCount(){
        Integer goodsCount = goodsService.wxGoodsCount();
        return BaseRespVo.ok(goodsCount);
        }

/**
 *
 * @author qys
 * @date 2022/9/9 20:50
 * @return BaseRespVo
 */
    @GetMapping("category")
    public BaseRespVo wxGoodsCategory(Integer id) {
            WXGoodsCategoryVO wxGoodsCategoryVO = goodsService.wxGoodsCategory(id);
            return BaseRespVo.ok(wxGoodsCategoryVO);
    }


    @SearchRecordAdvice
    @GetMapping("list")
    public BaseRespVo wxGoodsList(Integer categoryId, Integer brandId, boolean isHot, boolean isNew, String keyword, BasePageInfo basePageInfo) {
        WXGoodsListVO result = goodsService.wxGoodsList(categoryId, brandId, isHot, isNew, keyword, basePageInfo);
        return BaseRespVo.ok(result);
    }

    @FootprintAdvice
    @GetMapping("detail")
    public BaseRespVo wxGoodsDetail(Integer id) {
            WXGoodsDetailVO wxGoodsDetailVO = goodsService.wxGoodsDetail(id);
            return BaseRespVo.ok(wxGoodsDetailVO);
    }

    @GetMapping("related")
    public BaseRespVo wxGoodsRelated(Integer id) {
            WXGoodsRelatedVO wxGoodsRelatedVO = goodsService.wxGoodsRelated(id);
            return BaseRespVo.ok(wxGoodsRelatedVO);
    }
}
